﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace BambooGenTool.Helper
{
    public class UIGenerateHelper
    {
        public UIGenerateHelper()
        {
        }
        public string GetObjectInputFieldType(PropertyInfo property)
        {
            return "ComboBox";
        }
        public string GetObjectInputFieldName(PropertyInfo property)
        {
            return "cb" + property.Name;
        }
        public string GetGridColumnFieldType(PropertyInfo property)
        {
            string propertyTypeName = property.PropertyType.Name.ToLower();
            string result = "";
            if (propertyTypeName == "bool" || propertyTypeName == "boolean")
            {
                result = "DataGridViewCheckBoxColumn";
            } else {
                result = "DataGridViewTextBoxColumn";
            }
            return result;

        }
        public string GetBasicInputFieldType(PropertyInfo property)
        {
            string propertyTypeName = property.PropertyType.Name.ToLower();
            string result = "";
            if (propertyTypeName == "string")
            {
                result = "TextBox";
            }
            else if (propertyTypeName == "float" || propertyTypeName == "double")
            {
                result = "FloatNumberField";
            }
            else if (propertyTypeName == "int" || propertyTypeName.StartsWith("int") ||
                propertyTypeName == "long")
            {
                result = "IntergerNumberField";
            }

            else if (propertyTypeName == "bool" || propertyTypeName == "boolean")
            {
                result = "CheckBox";
            }
            else if (propertyTypeName == "datetime")
            {
                result = "DateTextBox";
            }
            return result;
        }
        public string GetLabelFieldName(PropertyInfo property)
        {
            return "lbl" + property.Name;
        }

        public string GetBasicInputFieldName(PropertyInfo property)
        {
            string propertyTypeName = property.PropertyType.Name.ToLower();
            string result = "";
            if (propertyTypeName == "string" || 
                propertyTypeName == "int" || propertyTypeName.StartsWith("int") || 
                propertyTypeName == "long" ||
                propertyTypeName == "float" ||
                propertyTypeName == "double")
            {
                result = "txt" + property.Name;
            }
            else if (propertyTypeName == "bool" || propertyTypeName == "boolean")
            {
                result = "chk" + property.Name;
            }
            else if (propertyTypeName == "datetime")
            {
                result = "dt" + property.Name;
            }
            return result;
        }

        public string GetInputPropertyOfInputField(PropertyInfo property)
        {
            string inputControl = GetBasicInputFieldType(property);
            string result = "";
            if (inputControl == "TextBox")
            {
                result = "Text";
            }
            else if (inputControl == "FloatNumberField" ||  inputControl=="IntergerNumberField")
            {
                result = "NumericValue";
            }
            else if (inputControl == "CheckBox")
            {
                result = "Checked";
            }
            else if (inputControl == "DateTextBox")
            {
                result = "Value";
            }
            return result;
        }
    }
}
